
/*
 * Class for treeObject
 */
function myTreeElement(){
	this.label = new String();
	this.expanded = new Boolean();
	this.children = new Array();
}
myTreeElement.prototype.setLabel = function(label){
    this.label = label;
}
myTreeElement.prototype.setExpanded = function(expanded){
    this.expanded = expanded;
}
myTreeElement.prototype.addChildren = function(children){
    this.children.push(children);
}

/*
 * Class for annotation Result structure.
 */ 
function myAnnotationResult(){
	this.kv = {
			features: new Array(),
			segment: null
		};
	this.cv  = {
			features: new Array(),
			segment: null
		};
	this.bv  = {
			features: new Array(),
			segment: null
		};
	this.zv  = {
			features: new Array(),
			segment: null
		};
	this.higherDefinitionView = "Kv";
}

myAnnotationResult.prototype.setKvFeatures = function(features){
    this.kv.features = features;
}
myAnnotationResult.prototype.setCvFeatures = function(features){
    this.cv.features = features;
}
myAnnotationResult.prototype.setBvFeatures = function(features){
    this.bv.features = features;
}
myAnnotationResult.prototype.setZvFeatures = function(features){
    this.zv.features = features;
}

myAnnotationResult.prototype.setKvSegment = function(segment){
    this.kv.segment = segment;
}
myAnnotationResult.prototype.setCvSegment = function(segment){
    this.cv.segment = segment;
}
myAnnotationResult.prototype.setBvSegment = function(segment){
    this.bv.segment = segment;
}
myAnnotationResult.prototype.setZvSegment = function(segment){
    this.zv.segment = segment;
}

myAnnotationResult.prototype.setHigherDefinitionView = function(viewType){
	var objectView = new Object();
	objectView["Kv"]= 0;
	objectView["Cv"]= 1;
	objectView["Bv"]= 2;
	objectView["Zv"]= 3;
	var higherDefinitionView_temp = this.higherDefinitionView;
	if(objectView[viewType] > objectView[higherDefinitionView_temp]){
		this.higherDefinitionView = viewType;
	}
}

/*
 * Class for Chromosome.
 */ 
function myChromosome(){
	bands = null;
	url = new String();
}


/*
 * Class for ENSEMBL DSN XML files.
 */ 
function myEnsemblDsn(){
    this.sourceId = new String();
    this.referenceUrl = new String();
    this.description = new String();
    this.dsnUrl = new String();
    this.sourceUrl = new String();
    this.sourceSpecie = new String();
    this.sourceRelease = new String();
    this.sourceType = new String();
}

myEnsemblDsn.prototype.setDsnUrl = function(dsnUrl){
    this.dsnUrl = dsnUrl;
}
myEnsemblDsn.prototype.setSourceId = function(sourceId){
    this.sourceId = sourceId;
  
    var splitDsnUrl = this.dsnUrl.split("/dsn");
    this.sourceUrl = splitDsnUrl[0] + "/" + sourceId;
  
    sId = YAHOO.dasBrowser.genome.karyotypeStructure.dsn.splitEnsemblDsnSourceId(sourceId);
	this.sourceSpecie = sId.sourceSpecie;
	this.sourceRelease = sId.sourceRelease;
	this.sourceType = sId.sourceType;

}
myEnsemblDsn.prototype.setMapmaster = function(mapmaster){
    this.referenceUrl = mapmaster;
}
myEnsemblDsn.prototype.setDescription = function(description){
    this.description = description;
}

myEnsemblDsn.prototype.getSourceId = function(){
    return this.sourceId;
}
myEnsemblDsn.prototype.getReferenceUrl = function(){
    return this.referenceUrl;
}
myEnsemblDsn.prototype.getDescription = function(){
    return this.description;
}
myEnsemblDsn.prototype.getSourceSpecie = function(){
    var sourceSpecie = this.sourceIdArray[0];
    return sourceSpecie.replace(/_/, " ");
}
myEnsemblDsn.prototype.getSourceRelease = function(){
    return this.sourceRelease;
}
myEnsemblDsn.prototype.getSourceType = function(){
    return this.sourceType.replace(/_/, " ");
}
myEnsemblDsn.prototype.getSourceUrl = function(){
    return this.sourceUrl;
}
myEnsemblDsn.prototype.getDsnUrl = function(){
    return this.dsnUrl;
}





/*
 * Class for ENSEMBL DSN XML files.
 */ 
function myDsn(){
    this.sourceId = new String();
    this.mapmaster = new String();
    this.description = new String();
}

myDsn.prototype.setDsnUrl = function(dsnUrl){
    this.dsnUrl = dsnUrl;
}
myDsn.prototype.setSourceId = function(sourceId){
    this.sourceId = sourceId;
}

myDsn.prototype.setMapmaster = function(mapmaster){
    this.mapmaster = mapmaster;
}

myDsn.prototype.setDescription = function(description){
    this.description = description;
}

myDsn.prototype.getSourceId = function(){
    return this.sourceId;
}
myDsn.prototype.getMapmaster = function(){
    return this.referenceUrl;
}
myDsn.prototype.getDescription = function(){
    return this.description;
}
myDsn.prototype.getDsnUrl = function(){
    return this.dsnUrl;
}







this.end = new String();
/*
 * Class for ENSEMBL Entry Points XML files.
 */ 
function myEnsemblEntryPoints(){
    this.type = new String();
    this.id = new String();
    this.start = new Number();
    this.stop = new Number();
	this.length = new Number();
    this.orientation = new String();
    this.subparts = new String();
    this.segment = new String();
}
myEnsemblEntryPoints.prototype.setType = function(type){
    this.type = type;
}
myEnsemblEntryPoints.prototype.setId = function(id){
    this.id = id;
}
myEnsemblEntryPoints.prototype.setStart = function(start){
    this.start = start;
	if(this.stop > 0){
		this.length = this.stop - this.start + 1;
	}
}
myEnsemblEntryPoints.prototype.setStop = function(stop){
    this.stop = stop;
	if(this.start > 0){
		this.length = this.stop - this.start + 1;
	}
}
myEnsemblEntryPoints.prototype.setOrientation = function(orientation){
    this.orientation = orientation;
}
myEnsemblEntryPoints.prototype.setSubparts = function(subparts){
    this.subparts = subparts;
}
myEnsemblEntryPoints.prototype.setSegment = function(segment){
    this.segment = segment;
}

myEnsemblEntryPoints.prototype.getType = function(){
    return this.type;
}
myEnsemblEntryPoints.prototype.getId = function(){
    return this.id;
}
myEnsemblEntryPoints.prototype.getStart = function(){
    return this.start;
}
myEnsemblEntryPoints.prototype.getStop = function(){
    return this.stop;
}
myEnsemblEntryPoints.prototype.getOrientation = function(){
    return this.orientation;
}
myEnsemblEntryPoints.prototype.getSubparts = function(){
    return this.subparts;
}
myEnsemblEntryPoints.prototype.getSegment = function(){
    return this.segment;
}

/*
 * Class for ENSEMBL Karyotype Stylesheet XML files.
 */ 
function myStylesheet(){
    this.categoryId = new String();
    this.typeId = new String();
    this.height = new String();
    this.label = new String();
    this.bgcolor = new String();
    this.fgcolor = new String();
    this.bump = new String();
}
myStylesheet.prototype.setCategoryId = function(categoryId){
    this.categoryId = categoryId;
}
myStylesheet.prototype.setTypeId = function(typeId){
    this.typeId = typeId.toLowerCase();
}
myStylesheet.prototype.setHeight = function(height){
    this.height = height;
}
myStylesheet.prototype.setLabel = function(label){
    this.label = label;
}
myStylesheet.prototype.setBgcolor = function(bgcolor){
    this.bgcolor = bgcolor;
}
myStylesheet.prototype.setFgcolor = function(fgcolor){
    this.fgcolor = fgcolor;
}
myStylesheet.prototype.setBump = function(bump){
    this.bump = bump;
}

myStylesheet.prototype.getCategoryId = function(){
    return this.categoryId;
}
myStylesheet.prototype.getTypeId = function(){
    return this.TypeId;
}
myStylesheet.prototype.getHeight = function(){
    return this.height;
}
myStylesheet.prototype.getLabel = function(){
    return this.label;
}
myStylesheet.prototype.getBgcolor = function(){
    return this.bgcolor;
}
myStylesheet.prototype.getFgcolor = function(){
    return this.fgcolor;
}
myStylesheet.prototype.getBump = function(){
    return this.bump;
}



/*
 * Class for Annotation feature XML files.
 */ 
function myAnnotationSegment(){
    this.id = new String();
    this.start = new String();
    this.stop = new String();
	this.type = new String();
	this.version = new String();
	this.label = new String();
	this.highestScore = null;
	this.lowestScore = null;
	this.positional = 0;
	this.nonPositional = 0;
	this.featureTypes = new Object(); // [typeName]=number
	this.featureMethods = new Array(); // [methodName]=number
	this.featureCategories = new Array(); // [categoryName]=number
	this.featureNumber = 0; //561; // Temp. Correct asap.
	this.featureNumberDisplayed = 0;
}
myAnnotationSegment.prototype.setId = function(id){
    this.id = id;
}
myAnnotationSegment.prototype.setStart = function(start){
    this.start = start;
}
myAnnotationSegment.prototype.setStop = function(stop){
    this.stop = stop;
}
myAnnotationSegment.prototype.setType = function(type){
    this.type = type;
}
myAnnotationSegment.prototype.setVersion = function(version){
    this.version = version;
}
myAnnotationSegment.prototype.setLabel = function(label){
    this.label = label;
}
myAnnotationSegment.prototype.addScore = function(score){
	if(YAHOO.lang.isNumber(parseFloat(score))){
		var newScore = parseFloat(score);
	} else {
		var newScore = 0;
	}

	// Highest Score
	var highestScoreTemp = this.highestScore;
	if(highestScoreTemp == null){
		this.highestScore = newScore;
	} else {
		if(newScore > highestScoreTemp){
			this.highestScore = newScore;
		}
	}
	// Lowest Score
	var lowestScoreTemp = this.lowestScore;
	if(lowestScoreTemp == null){
		this.lowestScore = newScore;
	} else {
		if(newScore < lowestScoreTemp){
			this.lowestScore = newScore;
		}
	}
}
myAnnotationSegment.prototype.setPositional = function(){
    this.positional++;
}
myAnnotationSegment.prototype.setNonPositional = function(){
    this.nonPositional++;
}

myAnnotationSegment.prototype.setFeatureNumber = function(score){
	var score = score.toString();
	var scoreValues = score.split("/");
	this.featureNumber = parseInt(scoreValues[1]);
	this.featureNumberDisplayed = parseInt(scoreValues[0]);
}
myAnnotationSegment.prototype.addFeatureType = function(type){
	if(type == null || type == "null" || type== ""){
		var typeValue = "Empty";
	} else {
		var typeValue = type; //type.replace(/:/g, "_");
	}

	if(this.featureTypes[typeValue]){var isItddefined = true;} else {isItddefined = false;}

	if(isItddefined) {
		var featureTypesNum = this.featureTypes[typeValue];
		this.featureTypes[typeValue] = featureTypesNum + 1;
	} else {
		this.featureTypes[typeValue] = 1;
	}
	//console.log(typeValue + ': ' +this.featureTypes[typeValue]);	
}

myAnnotationSegment.prototype.addFeatureMethod = function(method){
	if(method == null || method == "null" || method == ""){
		var methodValue = "Empty";
	} else {
		var methodValue = method; //method.replace(/:/g, "_");
	}

	if(this.featureMethods[methodValue]){var isItddefined = true;} else {isItddefined = false;}

	if(isItddefined) {
		var featureMethodsNum = this.featureMethods[methodValue];
		this.featureMethods[methodValue] = featureMethodsNum + 1;
	} else {
		this.featureMethods[methodValue] = 1;
	}
}
myAnnotationSegment.prototype.addFeatureCategory = function(category){
	if(category == null || category == "null" || category== ""){
		var categoryValue = "Empty";
	} else {
		var categoryValue = category; //type.replace(/:/g, "_");
	}

	if(this.featureCategories[categoryValue]){var isItddefined = true;} else {isItddefined = false;}

	if(isItddefined) {
		var featureCategoriesNum = this.featureCategories[categoryValue];
		this.featureCategories[categoryValue] = featureCategoriesNum + 1;
	} else {
		this.featureCategories[categoryValue] = 1;
	}
}



myAnnotationSegment.prototype.getId = function(){
    return this.id;
}
myAnnotationSegment.prototype.getStart = function(){
    return this.start;
}
myAnnotationSegment.prototype.getStop = function(){
    return this.stop;
}
myAnnotationSegment.prototype.getType = function(){
    return this.type;
}
myAnnotationSegment.prototype.getVersion = function(){
    return this.version;
}
myAnnotationSegment.prototype.getLabel = function(){
    return this.label;
}
myAnnotationSegment.prototype.getPositional = function(){
    return this.positional;
}
myAnnotationSegment.prototype.getNonPositional = function(){
    return this.nonPositional;
}
myAnnotationSegment.prototype.getTempScore = function(){
	return this.tempScore;
}
/*
 * Class for Annotation feature XML files.
 */ 
function myAnnotationFeature(){
    this.id = new String();
	this.label = new String();
    this.start = new String();
    this.end = new String();
	this.length = new String();
    this.typeId = new String();
    this.typeCategory = "";
	this.typeReference = new String();
    this.typeName = new String();
    this.methodId = new String();
	this.methodName = new String();
	this.score = null;
	this.tempScore = null;
    this.orientation = new String();
	this.phase = new String();
	this.note = new String();
	this.linkText = new String();
	this.linkUrl = new String();
	this.groupId = new String();
	this.groupLabel = new String();
	this.groupType = new String();
	this.targetName = new String();
	this.targetId = new String();
	this.targetStart = new String();
	this.targetStop = new String();
	this.positional = true;
}
myAnnotationFeature.prototype.setId = function(id){
    this.id = id;
}
myAnnotationFeature.prototype.setLabel = function(label){
    this.label = label;
}
myAnnotationFeature.prototype.setStart = function(start){
    this.start = start;
	if(this.stop > 0){
		this.length = this.stop - this.start + 1;
	}
}
myAnnotationFeature.prototype.setEnd = function(end){
    this.end = end;
	if(this.start > 0){
		this.length = this.end - this.start + 1;
	}
}
myAnnotationFeature.prototype.setTypeId = function(typeId){
    this.typeId = typeId.toLowerCase();
}
myAnnotationFeature.prototype.setTypeCategory = function(typeCategory){
    this.typeCategory = typeCategory;
}
myAnnotationFeature.prototype.setTypeReference = function(typeReference){
    this.typeReference = typeReference;
}
myAnnotationFeature.prototype.setTypeName = function(typeName){
    this.typeName = typeName;
}
myAnnotationFeature.prototype.setMethodId = function(methodId){
    this.methodId = methodId;
}
myAnnotationFeature.prototype.setMethodName = function(methodName){
    this.methodName = methodName;
}
myAnnotationFeature.prototype.setScore = function(score){
	this.tempScore = score;
	if (YAHOO.lang.isNumber(parseFloat(score))) {
		this.score = parseFloat(score);
	} else {
		this.score = "";
	}
	//this.score = Math.random(); // TESTING PURPOSES: delete this as soon as possible
}
myAnnotationFeature.prototype.setOrientation = function(orientation){
    this.orientation = orientation;
}
myAnnotationFeature.prototype.setPhase = function(phase){
    this.phase = phase;
}
myAnnotationFeature.prototype.setNote = function(note){
    this.note = note;
}
myAnnotationFeature.prototype.setLinkText = function(linkText){
    this.linkText = linkText;
}
myAnnotationFeature.prototype.setLinkUrl = function(linkUrl){
    this.linkUrl = linkUrl;
}
myAnnotationFeature.prototype.setGroupId = function(groupId){
    this.groupId = groupId;
}
myAnnotationFeature.prototype.setGroupLabel = function(groupLabel){
    this.groupLabel = groupLabel;
}
myAnnotationFeature.prototype.setGroupType = function(groupType){
    this.groupType = groupType;
}
myAnnotationFeature.prototype.setTargetName = function(targetName){
    this.targetName = targetName;
}
myAnnotationFeature.prototype.setTargetId = function(targetId){
    this.targetId = targetId;
}
myAnnotationFeature.prototype.setTargetStart = function(targetStart){
    this.targetStart = targetStart;
}
myAnnotationFeature.prototype.setTargetStop = function(targetStop){
    this.targetStop = targetStop;
}
myAnnotationFeature.prototype.setPositional = function(positional){
    this.positional = positional;
}

myAnnotationFeature.prototype.getId = function(){
    return this.id;
}
myAnnotationFeature.prototype.getLabel = function(){
    return this.label;
}
myAnnotationFeature.prototype.getStart = function(){
    return this.start;
}
myAnnotationFeature.prototype.getEnd = function(){
    return this.end;
}
myAnnotationFeature.prototype.getTypeId = function(){
    return this.typeId;
}
myAnnotationFeature.prototype.getTypeCategory = function(){
    return this.typeCategory;
}
myAnnotationFeature.prototype.getTypeReference = function(){
    return this.typeReference;
}
myAnnotationFeature.prototype.getTypeName = function(){
    return this.typeName;
}
myAnnotationFeature.prototype.getMethodId = function(){
    return this.methodId;
}
myAnnotationFeature.prototype.getMethodName = function(){
    return this.methodName;
}
myAnnotationFeature.prototype.getScore = function(){
    return this.score;
}
myAnnotationFeature.prototype.getOrientation = function(){
    return this.orientation;
}
myAnnotationFeature.prototype.getPhase = function(){
    return this.phase;
}
myAnnotationFeature.prototype.getNote = function(){
    return this.note;
}
myAnnotationFeature.prototype.getLinkText = function(){
    return this.linkText;
}
myAnnotationFeature.prototype.getLinkUrl = function(){
    return this.linkUrl;
}
myAnnotationFeature.prototype.getGroupId = function(){
    return this.groupId;
}
myAnnotationFeature.prototype.getGroupLabel = function(){
    return this.groupLabel;
}
myAnnotationFeature.prototype.getGroupType = function(){
    return this.groupType;
}
myAnnotationFeature.prototype.getPositional = function(){
    return this.positional;
}

/*
 * Class for Annotation feature XML files.
 */ 
function myFeaturePosition(){
    this.featureStartSeq = new Number();
	this.featureEndSeq = new Number();
	this.referenceStartSeq = new Number();
	this.referenceEndSeq = new Number();
	this.referenceLengthPx = new Number();
	
	this.featureLengthSeq = new Number();
	this.referenceLengthSeq = new Number();
	this.featureStartPx = new Number();
	this.featureEndPx =  new Number();
	this.featureLengthPx = new Number();
	
	this.track = null;
	
}
myFeaturePosition.prototype.setTrack = function(trackNumber){
    this.track = trackNumber;
}
myFeaturePosition.prototype.setReferenceLengthPx = function(referenceLengthPx){
    this.referenceLengthPx = YAHOO.dasBrowser.util.deletePxSuffix(referenceLengthPx);
	//alert(this.referenceLengthPx);
}
myFeaturePosition.prototype.setFeatureStartSeq = function(featureStartSeq){
    this.featureStartSeq = parseInt(featureStartSeq);
	//alert(this.featureStartSeq);
}
myFeaturePosition.prototype.setFeatureEndSeq = function(featureEndSeq){
    this.featureEndSeq = parseInt(featureEndSeq);
	//alert(this.featureEndSeq);
}
myFeaturePosition.prototype.setReferenceStartSeq = function(referenceStartSeq){
    this.referenceStartSeq = parseInt(referenceStartSeq);
	//alert(this.referenceStartSeq);
}
myFeaturePosition.prototype.setReferenceEndSeq = function(referenceEndSeq){
	this.referenceEndSeq = parseInt(referenceEndSeq);
	//alert(this.referenceEndSeq);
}

myFeaturePosition.prototype.calculatePx = function(){
	this.featureLengthSeq = this.featureEndSeq - this.featureStartSeq + 1;
	this.referenceLengthSeq = this.referenceEndSeq - this.referenceStartSeq + 1;
	var lettersPerPx = this.referenceLengthSeq / this.referenceLengthPx;
	var featureStartPxTemp = ((this.featureStartSeq - this.referenceStartSeq + 1)/ lettersPerPx) -(1/lettersPerPx) -0.5;
	if(featureStartPxTemp < 0){
		this.featureStartPx = 0;
	} else {
		this.featureStartPx = featureStartPxTemp;
	}
	this.featureLengthPx = (this.featureLengthSeq / lettersPerPx ) - 0.01;
	this.featureEndPx = this.featureStartPx + this.featureLengthPx;
}






/*
 * Class for Coordinates information on Sources from the DAS Registry.
 */ 
function myDasSourceCoordinates(){
    this.uri = new String();
	this.source = new String();
	this.authority = new String();
	this.testRange = new String();
	this.name = new String();
}
myDasSourceCoordinates.prototype.setUri = function(uri){
    this.uri = uri;
}
myDasSourceCoordinates.prototype.setSource = function(source){
    this.source = source;
}
myDasSourceCoordinates.prototype.setAuthority = function(authority){
    this.authority = authority;
}
myDasSourceCoordinates.prototype.setTestRange = function(testRange){
    this.testRange = testRange;
}
myDasSourceCoordinates.prototype.setName = function(name){
    this.name = name;
}

/*
 * Class for Capability information on Sources from the DAS Registry.
 */ 
function myDasSourceCapability(){
    this.type = new String();
	this.queryUri = new String();
}
myDasSourceCapability.prototype.setType = function(type){
    this.type = type;
}
myDasSourceCapability.prototype.setQueryUri = function(queryUri){
    this.queryUri = queryUri;
}


/*
 * Class for Label information on Sources from the DAS Registry.
 */ 
function myDasSourceProp(){
    this.name = new String();
	this.value = new String();
}
myDasSourceProp.prototype.setName = function(name){
    this.name = name;
}
myDasSourceProp.prototype.setValue = function(value){
    this.value = value;
}


/*
 * Class for Sources from the DAS Registry.
 */ 
function myDasSource(){
    this.uri = new String();
	this.title = new String();
	this.docHref = new String();
	this.description = new String();
	this.maintainerEmail = new String();
	this.versionUri = new String();
	this.versionCreated = new String();
	this.projectHome = null;
	this.projectIcon = null;
	this.projectDesc = null;
	this.projectName = null;
	this.leaseTime = null;
	
	this.coordinates = new Array();
    this.label = new Array();
    this.capability = new Array();
}

myDasSource.prototype.setUri = function(uri){
    this.uri = uri;
}
myDasSource.prototype.setTitle = function(title){
    this.title = title;
}
myDasSource.prototype.setDocHref = function(docHref){
    this.docHref = docHref;
}
myDasSource.prototype.setDescription = function(description){
    this.description = description;
}
myDasSource.prototype.setMaintainerEmail = function(maintainerEmail){
    this.maintainerEmail = maintainerEmail;
}
myDasSource.prototype.setVersionUri = function(versionUri){
    this.versionUri = versionUri;
}
myDasSource.prototype.setVersionCreated = function(versionCreated){
    this.versionCreated = versionCreated;
}
myDasSource.prototype.setProjectHome = function(projectHome){
    this.projectHome = projectHome;
}
myDasSource.prototype.setProjectIcon = function(projectIcon){
    this.projectIcon = projectIcon;
}
myDasSource.prototype.setProjectDesc = function(projectDesc){
    this.projectDesc = projectDesc;
}
myDasSource.prototype.setProjectName = function(projectName){
    this.projectName = projectName;
}
myDasSource.prototype.setLeaseTime = function(leaseTime){
    this.leaseTime = leaseTime;
}
myDasSource.prototype.addCoordinates = function(coordinates){
    this.coordinates.push(coordinates);
}
myDasSource.prototype.addLabel = function(label){
    this.label.push(label);
}
myDasSource.prototype.addCapability = function(capability){
    this.capability.push(capability);
}

